<?php require_once("header.php");?>   
<?php require_once("php/carousel.php");?>        
<?php if(isset($_GET['tag']) && isset($_GET['tid'])):
	$tag = $_GET['tag'];
	$tid = $_GET['tid'];
else:
	return;
endif;?>
<?php $recipes = json_decode(api("all_recipes/".$user_id."/".$tid,"GET",null),true);?> 
<h3>"<?php echo $tag;?>" Recipes</h3>

<?php //print_r($recipes);?>

<br />
<input type="text" class="tags filter" placeholder="Filter by tags or ingredients. (ex: Breakfast, Kid Friendly, Sandwich)" />
<input id="filter" type="button" value="Filter Recipes" />

<div id="your" class="recipe_carousel">
<?php foreach($recipes as $recipe):?>
		<div class="thumbnail <?php echo getClasses($recipe);?>">
            <img alt="" src="php/photo.php?recipe_id=<?php echo $recipe['rid'];?>" /><br />
            <input type="hidden" value="<?php echo $recipe['rid'];?>" />
            <div class="recipe-details"><?php echo carouselDetails($recipe);?></div>
        </div>
<?php endforeach;?>
</div><!-- carousel -->

<script>
setFilter();

// tags
<?php $tags = api("tags/","GET",null);?>
var tempTags = <?php echo $tags;?>;
var tags = new Array();
for(var i=0; i<tempTags.length; i++){
	tags[i] = tempTags[i]['name'];;
}

// ingredients
<?php $ingredients = api("ingredients/","GET",null);?>
var tempIngredients = <?php echo $ingredients;?>;
var ingredients = new Array();
for(var i=0; i<tempIngredients.length; i++){
	ingredients[i] = tempIngredients[i]['name'];;
}

var combined = tags.concat(ingredients);
setAutoComplete("tags",false,combined,true);
</script>

<?php require_once("footer.php");?>    